package sistemioperativi.prodcons.sample;

import java.util.concurrent.TimeUnit;

public class Consumatore implements Runnable {

	private Buffer buffer;
	
	public Consumatore(Buffer buffer){
		this.buffer = buffer;
	}
	
	public void run() {
		
		try{
			while(true){
			
				Elemento e = buffer.get();
				consuma(e);
				
			} 
		}catch(InterruptedException e){};
		
	}// run

	private void consuma(Elemento e) throws InterruptedException {
		
		TimeUnit.SECONDS.sleep(e.getValore());
	
	}


}// EOC
